export function randInt(min: number, max: number = 0) {
    if (min > max) {
        const tmp = max;
        max = min;
        min = tmp;
    }
    return Math.floor(Math.random() * (max - min) + min);
}

export function floatVal(str: string | number, nanText: string | number = 0): string | number {
    const num = parseFloat(str.toString());
    if (isNaN(num)) {
        return nanText;
    }
    return num;
}

export function intVal(str: string | number, nanText: string | number = 0): string | number {
    const num = parseInt(str.toString(), 10);
    if (isNaN(num)) {
        return nanText;
    }
    return num;
}
